<template>
    <el-row>
        <el-row>
            <el-form :model="formInline"
                class="search_prod"
                label-width="120px">
                <el-form-item label="用户昵称">
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">
                            <el-input size="small"
                                clearable
                                v-model.number="formInline.nickname"></el-input>
                        </el-col>
                    </el-col>
                    <el-col class="tr col_label"
                        :span="3">会员账号&nbsp;&nbsp;&nbsp;</el-col>
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">
                            <el-input size="small"
                                clearable
                                v-model.number="formInline.username"></el-input>
                        </el-col>
                    </el-col>
                    <el-col class="tr col_label"
                        :span="3">订单号&nbsp;&nbsp;&nbsp;</el-col>
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">
                            <el-input size="small"
                                clearable
                                v-model.number="formInline.oid"></el-input>
                        </el-col>
                    </el-col>
                </el-form-item>
                <el-form-item label="提现状态">
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">
                            <el-select v-model="formInline.status"
                                clearable
                                size="small"
                                placeholder="请选择提现状态">
                                <el-option v-for="item in statusList"
                                    size="small"
                                    :key="item.id"
                                    :label="item.title"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-col>
                    <el-col class="tr col_label"
                        :span="3">提现方式&nbsp;&nbsp;&nbsp;</el-col>
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">
                            <el-select v-model="formInline.pay"
                                clearable
                                size="small"
                                placeholder="请选择提现方式">
                                <el-option v-for="item in payList"
                                    size="small"
                                    :key="item.id"
                                    :label="item.title"
                                    :value="item.id">
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-col>

                    <el-col class="tr col_label"
                        :span="3">金额类型&nbsp;&nbsp;&nbsp;</el-col>
                    <el-col :span="4">
                        <el-col :span="16"
                            class="search_input_width">

                            <el-select v-model="formInline.cate"
                                clearable
                                size="small"
                                placeholder="请选择金额类型">
                                <el-option v-for="item in list"
                                    size="small"
                                    :key="item.id"
                                    :label="item.label"
                                    :value="item.value">
                                </el-option>
                            </el-select>
                        </el-col>
                    </el-col>

                </el-form-item>

                <el-form-item label="时间">
                    <el-col :span="4">
                        <el-col :span="22"
                            class="search_time_width">
                            <el-date-picker style="width:100%"
                                v-model="createTime"
                                type="datetimerange"
                                size="small"
                                align="right"
                                unlink-panels
                                clearable
                                value-format="timestamp"
                                range-separator="-"
                                start-placeholder="开始日期"
                                end-placeholder="结束日期"
                                :picker-options="pickerOptions2">
                            </el-date-picker>
                        </el-col>
                    </el-col>
                </el-form-item>
                <el-form-item>
                    <el-row class="tl">
                        <el-col :span="24">
                            <el-button :loading='$store.state.isLoading'
                                size="mini"
                                type="primary"
                                @click="subOrderInfo">查询</el-button>
                            <el-button :loading='$store.state.isLoading'
                                size="mini"
                                type="primary"
                                @click="exportExcel">导出</el-button>
                            <el-button :loading='$store.state.isLoading'
                                size="mini"
                                type="primary"
                                @click="delOrderInfo">一键清除</el-button>
                        </el-col>
                    </el-row>
                </el-form-item>
            </el-form>
        </el-row>

    </el-row>
</template>
<script>
import address from "../../assets/js/address.js";
export default {
  name: "productSearch",
  data() {
    return {
      pickerOptions2: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      },
      createTime: [],
      formInline: {
        oid: "",
        nickname: "",
        username: "",
        pay: "",
        created_time_begin: "",
        created_time_end: "",
        status: "",
        cate: ""
      },
      payList: [
        { id: "支付宝", title: "支付宝" },
        { id: "微信", title: "微信" },
        { id: "银行卡", title: "银行卡" }
      ],
      statusList: [
        { id: "0", title: "申请中" },
        { id: "1", title: "审核成功" },
        { id: "2", title: "审核不成功" }
      ],
      list: this.$store.state.rewardOption
    };
  },
  methods: {
    exportExcel() {
      this.$fnc.postExcelFile(this.formInline, "/api/admin/export/withdraw");
    },
    delOrderInfo() {
      this.formInline = {
        oid: "",
        nickname: "",
        username: "",
        pay: "",
        created_time_begin: "",
        created_time_end: "",
        status: "",
        cate: ""
      };
      this.$emit("sendtixianSearch", this.formInline);
    },
    subOrderInfo() {
      this.$emit("sendtixianSearch", this.formInline);
    }
  },
  created() {
    // if (
    //   this.$route.query.action != undefined &&
    //   this.$route.query.action != null &&
    //   this.$route.query.action != ""
    // ) {
    //   var id = this.$route.query.action;
    //   this.formInline.status = id;
    //   this.$emit("sendtixianSearch", this.formInline);
    // }
  },
  watch: {
    // $route() {
    //   this.formInline.status = this.$route.query.action || "";
    //   this.$emit("sendtixianSearch", this.formInline);
    // },
    createTime(val) {
      if (val != null) {
        this.formInline.created_time_begin = this.$fnc.phptime(val[0]);
        this.formInline.created_time_end = this.$fnc.phptime(val[1]);
      } else {
        this.formInline.created_time_begin = "";
        this.formInline.created_time_end = "";
      }
    }
  }
};
</script>
